﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Web.SessionState;

using Danser_Entity.Entities;
using Danser_Entity.Queries.Data;


namespace Danser_AJAXEnabledWebApplication.User_Controls
{
    /// <summary>
    /// wrapper to hold the relevant information for an owner GraphUserControl
    /// </summary>
    public class GraphData
    {
        #region Constants:

        private const String SESSION_MAIN_TEST = "GraphControl.MainTest";
        private const String SESSION_MAIN_TEST_IDX = "GraphControl.MainTestIndex";
        private const String SESSION_ANCHORS = "GraphControl.Anchors";
        private const String SESSION_NEED_REDRAW = "GraphControl.needRedraw";

        #endregion

        #region Members:

        /// <summary>
        /// this object exists in the context of this session
        /// </summary>
        private HttpSessionState _session = null;

        #endregion

        #region C'tor:

        /// <summary>
        /// C'tor
        /// </summary>
        public GraphData(HttpSessionState session) 
        {
            _session = session;
            _session[SESSION_NEED_REDRAW] = false;
        }

        #endregion

        #region Properties:

        /// <summary>
        /// Main test selected to be viewed by the user
        /// </summary>
        public IList<TestIntegratedData> mGDmainTest
        {
            get { return _session[SESSION_MAIN_TEST] as IList<TestIntegratedData>; }//GDmainTest; }
            set 
            {
                _session[SESSION_MAIN_TEST] = value;
                _session[SESSION_NEED_REDRAW] = true;
            }
        }

        /// <summary>
        /// List of anchors to present against the selected main test
        /// </summary>
        public IList<IList<TestIntegratedData>> mGDanchorRef
        {
            get { return _session[SESSION_ANCHORS] as IList<IList<TestIntegratedData>>; }//GDanchorRef; }
            set 
            {
                _session[SESSION_ANCHORS] = value;
                _session[SESSION_NEED_REDRAW] = true;
            }
        }

        /// <summary>
        /// Main test's id as presented in DB layer, selected to be viewed by the user
        /// </summary>
        public String mGDmainTestIndex
        {
            get { return _session[SESSION_MAIN_TEST_IDX] as String; }
            set { _session[SESSION_MAIN_TEST_IDX] = value; }
        }

        /// <summary>
        /// Indicates whether the control needs to redraw the current graph
        /// </summary>
        public bool NeedRedraw
        {
            get { return (bool)_session[SESSION_NEED_REDRAW]; }
            set { _session[SESSION_NEED_REDRAW] = value; }
        }

        #endregion
    }
}